PROJECT(Plugin_Test)
CMAKE_MINIMUM_REQUIRED(VERSION 3.9)

SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -std=gnu++0x")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -std=gnu++0x")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -O2 -std=gnu++0x")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++0x -Wall -O2")

SET(PATH_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/./../../../demo/Plugin_Test/demo1/test)
SET(PATH_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/./../../../demo/Plugin_Test/demo1/src)
SET(PATH_PLUGIN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/./../../../demo/Plugin_Test/demo1/plugin)

INCLUDE_DIRECTORIES(${PATH_SRC_DIR})

FILE(GLOB_RECURSE PLUGIN_CPP_LIST ${PATH_PLUGIN_DIR}/*.cpp)
FILE(GLOB_RECURSE SRC_CPP_LIST ${PATH_SRC_DIR}/*.cpp)
FILE(GLOB_RECURSE TEST_CPP_LIST ${PATH_TEST_DIR}/*.cpp)

ADD_DEFINITIONS(-DDLL_EXPORTS)

IF(BUILD_PLUGIN)
	MESSAGE(STATUS "########## BUILD PLUGIN ##########")
    ADD_LIBRARY(plugin_area SHARED ${PLUGIN_CPP_LIST})
    SET_TARGET_PROPERTIES(plugin_area PROPERTIES PREFIX "" SUFFIX ".fbc")
ELSE()
	MESSAGE(STATUS "########## BUILD SRC AND TEST ##########")
    #SET(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) # can generate address.lib in windows
    ADD_LIBRARY(address SHARED ${SRC_CPP_LIST})  

    ADD_EXECUTABLE(Plugin_Test ${TEST_CPP_LIST})
    IF(WIN32)
        TARGET_LINK_LIBRARIES(Plugin_Test address)
    ELSE()
        TARGET_LINK_LIBRARIES(Plugin_Test address dl)
    ENDIF()
ENDIF()